import React from 'react'
import PropTypes from 'prop-types'
import { Table, Modal, Button, Icon } from 'antd'
import styles from './index.less'
import classnames from 'classnames'
import { AnimTableBody } from '../../components'
import { DropOption } from '../../components'
import { config } from '../../utils'
const confirm = Modal.confirm
const IMGURL = config.IMGURL



class list extends React.Component {
  state = {
    selectedRowKeys: [],  // Check here to configure the default column
    loadingDel: false,
  };

  render() {
    const {
       pagination,dataSource,onPageChange ,onRowDouble,onEdit,loading,location,autStatus
      } = this.props
    const customerType =(e)=>{
      let text =''
      switch(e){
            case 0:
                text = '公司管理员'
                break;
            case 5:
                text = '公司发货员'
                break;
            case 6:
                text = '普通用户'
                break;
            case 9:
                text = '司机'
                break;           
        }
        return text
    }
    const columns = [
      {
        title: '客户姓名',
        dataIndex: 'trueName',
        key: 'trueName',
      },{
        title: '客户头像',
        dataIndex: 'trueHead',
        key: 'trueHead',
        render:(text) => <img width='40' src={IMGURL+text}></img>
      },{
        title: '发货权限',
        dataIndex: 'empRight',
        key: 'empRight',
        render:(text) =><span>{text == 0? '无权限':'有权限'}</span>
      },{
        title: '驾驶证',
        dataIndex: 'driversLicense',
        key: 'driversLicense',
      },{
        title: ' 手机号码',
        dataIndex: 'mobile',
        key: 'mobile',
      },{
        title: '操作',
        key: 'operation',
        width: 100,
        render: (text, record) => {
          return <DropOption onMenuClick={e => handleMenuClick(record, e)} menuOptions={[{ key: '1', name: '详细' }]} />
        },
      },
    ]
    const onChange =(e)=>{
      const data = {
        page:JSON.stringify( e.current),
        pageSize:e.pageSize,
        autStatus:autStatus,
      }
      onPageChange(data)
    }
    const onRowDoubleClick =(record)=>{
      onRowDouble(record)
    }
    const handleMenuClick = (record, e) => {
      if (e.key === '1') {
         onRowDouble(record)
      }
    }

    return (
      <div>
      <div className={styles.filterTop}>
        <div className={styles.title}><span style={{marginRight:20}}>全部司机</span></div>
        <div className={styles.Searchright}>
        </div>
      </div>
      <div className={styles.listbox}>
        <div>
          <Table
            className={styles.table}
            bordered
            scroll={{ x: 750, y:600 }}
            columns={columns}
            dataSource={dataSource}
            loading={loading}
            onChange={onChange}
            pagination={pagination}
            onRowDoubleClick={onRowDoubleClick}
            simple
            rowKey={record => record.id}
          />
        </div>
      </div>
      </div>
    );
  }
}

list.propTypes = {
  loading: PropTypes.bool,
  dataSource: PropTypes.array,
  pagination: PropTypes.object,
  onPageChange: PropTypes.func,
  onDeleteItem: PropTypes.func,
  onEditItem: PropTypes.func,
  isMotion: PropTypes.bool,
  location: PropTypes.object,
}

export default list
